package com.lagou.task17;

import java.io.IOException;
import java.io.RandomAccessFile;

public class RandAccessFileTest {
    public static void main(String[] args) {
        RandomAccessFile accessFile = null;
        try {
            accessFile = new RandomAccessFile("a.txt", "rw");
            accessFile.seek(3);
            int res = accessFile.read();
            accessFile.write('2');//执行该行代码覆盖了原来位置的字符
            System.out.println((char)res);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                accessFile.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
